home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 233 / Computer Shopper 233 / ComputerShopperDVD233.iso / mpf / eng / shared / agentdui.cab / scui.dll / HTML / MPS.VBS < prev    next >
Encoding:
Text File  |  2005-07-27  |  19.0 KB  |  800 lines

  1. '/////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. 'Standard defines from MSCIFCONSTS.H
  3.  
  4. Const USER_TYPE_NONE      = 0
  5. Const USER_TYPE_ADMIN     = 1
  6. Const USER_TYPE_USER      = 2
  7.  
  8.  
  9. '/////////////////////////////////////////////////////////////////////////////////////////////////////////
  10. 'Function return values
  11.  
  12. Const CFGUSER_GENERIC_ERROR                     = -1
  13. Const CFGUSER_SUCCESS                           = 0
  14. Const CFGUSER_ERROR                             = 1
  15. Const CFGUSER_USER_ALREADY_PRESENT              = 2
  16. Const CFGUSER_PASSWORD_CHANGE_FAILED            = 3
  17. Const CFGUSER_LOGIN_FAILED                      = 4
  18. Const CFGUSER_NOUSER_LOGGED_IN                  = 5
  19. Const CFGUSER_WRONG_PASSWORD                    = 6
  20. Const CFGUSER_ANOTHER_USER_LOGGEDIN             = 7
  21. Const CFGUSER_GLOBALMUTEX_ERROR                 = 8
  22. Const CFGUSER_USER_LOGGEDIN_ANOTHER_SESSION     = 9
  23. Const CFGUSER_USER_INVALID_USER                 = 10
  24. Const CFGUSER_NO_DEFUSER                        = 11
  25.  
  26.  
  27. '/////////////////////////////////////////////////////////////////////////////////////////////////////////
  28. 'Command IDs (Update Boundry check variables if adding / deleting
  29.  
  30. Const ID_MSCIF_EXIT                   = 40001
  31. Const ID_USER_LOGIN                   = 40002
  32. Const ID_USER_LOGOUT                  = 40003
  33. Const ID_USER_CONFIGURATION           = 40004
  34. Const ID_MSCIF_SHUTDOWN               = 40005
  35. Const ID_MSCIF_DISABLE                = 40007
  36. Const ID_MSCIF_ENABLE                 = 40008
  37. Const ID_MSCIF_HELP                   = 40009
  38. Const ID_USER_LOGIN_ANDOR_CONFIG      = 40010
  39. Const ID_MSCIF_USERS                  = 40011
  40. Const ID_MSCIF_EVENTLOG               = 40012
  41. Const ID_MSCIF_ABOUT                  = 40013
  42. Const ID_MSCIF_CHECKEXPIRY              = 40014
  43.  
  44. ' Boundry condition check variables.
  45. ' NOTE: Update these values if adding an ID above
  46. Const ID_MSCIF_BEGIN_IDS              = 40001
  47. Const ID_MSCIF_END_IDS                    = 40014
  48.  
  49.  
  50. '/////////////////////////////////////////////////////////////////////////////////////////////////////////
  51. 'General constants
  52.  
  53. Const MPS_CLSID                          = "{13DB6EFF-AF1B-483e-8F7B-F1978AD6D4E1}"
  54. Const MPS_APP_NAME                      = "MscIfApp.exe"    
  55. Const MPS_CMDARG_VERIFY_STR              = "/Verify"
  56.  
  57. Const MPS6_CLSID                      = "{983DD781-10DA-4C25-8706-9E152DFCEF90}"
  58. Const MPS6_APPNAME                    = "guarddog.exe"
  59. Const MPS6_REGVAL_INSTALL_LOC         = "InstallLocation"
  60. Const MPS6_REG_KEY                    = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
  61. Const MPS6_MIN_VER                      = "6,0,0,0"
  62.  
  63. '/////////////////////////////////////////////////////////////////////////////////////////////////////////
  64. 'Error strings
  65.  
  66. Const ERR_SUCCEEDED                      = "Success."
  67. Const ERR_NO_MCINSTALL                  = "Failed to load the MCINSCTL App Helper Object."
  68. Const ERR_NO_MPSDISPATCH              = "Failed to acquire the MPS default Dispatch Interface."
  69. Const ERR_NO_REGOBJ                   = "Failed to get the registry object from MCINSCTL."
  70.  
  71. Const ERR_GETACTIONITEM_GENERIC_FAIL  = "Failed to get the list of Command IDs."
  72. Const ERR_INVOKECOMMAND_INVALID_CMD   = "Invalid command ID."
  73. Const ERR_INVOKECOMMAND_GENERIC_FAIL  = "Failed to invoke the command."
  74.  
  75. 'Following Consts are required to check if perpetual product is installed...
  76. Const REG_MPS_KEY                 = "HKLM\Software\McAfee.com\Privacy Service"
  77. Const REG_MPS_PRODUCTTYPE_NAME        = "ProductType"     '// Product information
  78. Const MPS_PRODUCT_INSTALL_TYPE_NODIE_NOUPDATES  = &H00000200
  79.  
  80. '/////////////////////////////////////////////////////////////////////////////////////////////////////////
  81. 'End Constants
  82.  
  83. Dim gobjMPSDisp, gmcAppHelper
  84.  
  85.  
  86. Function TestIt()
  87. '{
  88.  
  89.     Dim szError, itemArr
  90.     Dim eResult
  91.  
  92.     eResult = MPS_OnLoad()
  93.     If False = eResult Then
  94.         MsgBox "MPS_OnLoad() failed..."
  95.         Exit Function
  96.     End if
  97.  
  98.     eResult = MPS_GetActionItem(itemArr, szError)
  99.     If eResult <> CFGUSER_SUCCESS Then
  100.         MsgBox szError
  101.         Exit Function
  102.     End If
  103.  
  104.     If IsArray(itemArr) Then
  105.  
  106.         for nIdx = LBound(itemArr) To UBound(itemArr)
  107.            MsgBox "Index = " & nIdx & " : " & "Value = " & itemArr(nIdx)
  108.         Next
  109.  
  110.     End if
  111.  
  112.     eResult = gobjMPSDisp.InvokeCommand(40004)
  113.     Call MPS_OnUnLoad()
  114.  
  115. '}
  116. End Function
  117.  
  118. ' Call TestIt()
  119.  
  120.  
  121. Function GetObjectPath( sCLSID, objOS, objFS )
  122. '{
  123.     Dim   sPath
  124.  
  125.     GetObjectPath = ""
  126.     sPath = objOS.GetObjectModuleDir( sCLSID )
  127.     If "" = sPath Then
  128.     '{
  129.         Exit Function
  130.     '}
  131.     End If
  132.  
  133.     GetObjectPath = objFS.GetShortPathName( sPath )
  134. '}
  135. End Function
  136.  
  137. '0 == Application started
  138. '1 == Application could not be started
  139. Function LaunchProgram( szPath, szCmdLine, eResult )
  140. '{
  141.     eResult = 1
  142.  
  143.     If False = IsObject( g_localObjOS ) Then
  144.         LaunchProgram = eResult
  145.         Exit Function
  146.     End If
  147.  
  148.     If False = IsObject( g_localObjFS ) Then
  149.         LaunchProgram = eResult
  150.         Exit Function
  151.     End If
  152.  
  153.     If g_localObjOS is nothing Or _
  154.         g_localObjFS is nothing Then
  155.     '{
  156.         LaunchProgram = eResult
  157.         Exit Function
  158.     '}
  159.     End If
  160.  
  161.     If "" <> szPath And "" <> szCmdLine Then
  162.     '{
  163.         If 0 = g_localObjOS.RunProgram( szPath, CStr(szCmdLine) ) Then
  164.             eResult = 1
  165.         Else 
  166.             eResult = 0
  167.         End If
  168.     '}
  169.     End If
  170.     LaunchProgram = eResult
  171. '}
  172. End Function
  173.  
  174. ' MPS_OnLoad() returns FALSE on a failure.
  175. ' It returns TRUE on a success.
  176.  
  177. Function MPS_OnLoad(ByRef szError)
  178. '{
  179.  
  180.     Set gobjMPSDisp = nothing
  181.  
  182.     Set gmcAppHelper = g_localObjExternal.CreateObject(CLSID_CoMCAppHelper, CLSID_LIC, true )
  183.     If gmcAppHelper is nothing Then
  184.         szError = ERR_NO_MCINSTALL
  185.         MPS_OnLoad = False
  186.         Exit Function
  187.     End If
  188.  
  189.     szError = ERR_SUCCEEDED
  190.     MPS_OnLoad = True
  191.  
  192. '}
  193. End Function
  194.  
  195. Function MPS_OnUnload()
  196. '{
  197.     Set gmcAppHelper = nothing
  198.     Set gobjMPSDisp = nothing
  199. '}
  200. End Function
  201.  
  202. Function MPSDisp_OnUnload()
  203. '{
  204.     Set gobjMPSDisp = nothing
  205. '}
  206. End Function
  207.  
  208. Function MPS_ValidateObjects(ByRef szError)
  209. '{
  210.  
  211.     If gmcAppHelper is nothing Then
  212.     '{
  213.  
  214.         szError = ERR_NO_MCINSTALL
  215.         MPS_ValidateObjects = CFGUSER_ERROR
  216.  
  217.         Exit Function
  218.  
  219.     '}
  220.     End If
  221.  
  222.     If gobjMPSDisp is nothing Then
  223.     '{
  224.  
  225.         Set gobjMPSDisp = gmcAppHelper.GetObject( MPS_CLSID )
  226.  
  227.         If gobjMPSDisp is nothing Then
  228.             szError = ERR_NO_MPSDISPATCH
  229.             MPS_ValidateObjects = False
  230.             Exit Function
  231.         End If
  232.  
  233.     '}
  234.     End If
  235.  
  236.     MPS_ValidateObjects = CFGUSER_SUCCESS
  237.     szError = ERR_SUCCEEDED
  238.  
  239. '}
  240. End Function
  241.  
  242. ' MPS_GetActionItem() returns CFGUSER_ERROR on a failure and CFGUSER_SUCCESS on success.
  243. ' szError contains a description of the error. On success it will say "Success". Typically
  244. ' szError should be used only if an error was returned.
  245.  
  246. ' On return, "itemArr" will contain the list of Command IDs returned by MPS dispatch interface.
  247.  
  248. Function MPS_GetActionItem(ByRef itemArr, ByRef szError)
  249. '{
  250.  
  251.     Dim eResult
  252.  
  253.     eResult = MPS_ValidateObjects(szError)
  254.     If CFGUSER_SUCCESS <> eResult Then
  255.         MPS_GetActionItem = eResult
  256.         Exit Function
  257.     End if
  258.  
  259.     szError = ""
  260.  
  261.     eResult = gobjMPSDisp.GetActionItem(itemArr)
  262.     If eResult = CFGUSER_SUCCESS Then
  263.         szError = ERR_SUCCEEDED
  264.     Else
  265.         szError = ERR_GETACTIONITEM_GENERIC_FAIL
  266.     End If
  267.  
  268.     MPS_GetActionItem = eResult
  269.  
  270. '}
  271. End Function
  272.  
  273.  
  274. ' MPS_InvokeCommand() returns CFGUSER_ERROR on a failure and CFGUSER_SUCCESS on success.
  275. ' szError contains a description of the error. On success it will say "Success". Typically
  276. ' szError should be used only if an error was returned.
  277.  
  278. ' lCommandID is the command ID to be invoked.
  279.  
  280. Function MPS_InvokeCommand(lCommandID, ByRef szError)
  281. '{
  282.  
  283.     Dim eResult
  284.  
  285.     eResult = MPS_ValidateObjects(szError)
  286.     If CFGUSER_SUCCESS <> eResult Then
  287.         MPS_InvokeCommand = eResult
  288.         Exit Function
  289.     End if
  290.  
  291.     szError = ""
  292.  
  293.     If lCommandID < ID_MSCIF_BEGIN_IDS Or lCommandID > ID_MSCIF_END_IDS Then
  294.         MPS_InvokeCommand = CFGUSER_ERROR
  295.         szError = ERR_INVOKECOMMAND_INVALID_CMD
  296.         Exit Function
  297.     End If
  298.  
  299.     MPS_InvokeCommand = CFGUSER_ERROR
  300.     On Error Resume Next
  301.     eResult = gobjMPSDisp.InvokeCommand(lCommandID)
  302.     If eResult = CFGUSER_SUCCESS Then
  303.         szError = ERR_SUCCEEDED
  304.     Else
  305.         szError = ERR_INVOKECOMMAND_GENERIC_FAIL
  306.     End If
  307.  
  308.     MPS_InvokeCommand = eResult
  309.  
  310. '}
  311. End Function
  312.  
  313.  
  314. ' MPS_GetUserType() will return ADMIN, USER, or NONE (no user is logged in).
  315. ' The function returns USERTYPE_ERROR (-1) on error. szError contains the error
  316. ' string and typically it will make sense only when the return value is an error.
  317.  
  318. Function MPS_GetUserType(ByRef szError)
  319. '{
  320.  
  321.     MPS_GetUserType = CFGUSER_GENERIC_ERROR
  322.     eResult = MPS_ValidateObjects(szError)
  323.     If CFGUSER_SUCCESS <> eResult Then        
  324.         Exit Function
  325.     End if
  326.  
  327.     szError = ERR_SUCCEEDED
  328.     On Error Resume Next
  329.     MPS_GetUserType = gObjMPSDisp.get_LoginUserType()
  330.  
  331. '}
  332. End Function
  333.  
  334. ' True = Enabled, False = Disabled.
  335. ' szError returns a string description of the error. Typically should be used
  336. ' only if an error was returned.
  337.  
  338. ' The only error return value from this function is -1, or CFGUSER_GENERIC_ERROR
  339.  
  340. Function MPS_IsEnabled(ByRef szError)
  341. '{
  342.  
  343.     Dim bOldOfuscate, dwState
  344.  
  345.     szError = ERR_SUCCEEDED
  346.  
  347.     If g_localObjReg Is Nothing Then
  348.         MPS_IsEnabled = 1
  349.         szError = ERR_NO_REGOBJ
  350.         Exit Function
  351.     End If
  352.  
  353.     bOldOfuscate = g_localObjReg.obfuscate
  354.  
  355.     g_localObjReg.obfuscate = True
  356.  
  357.     dwState = g_localObjReg.RegQueryValue( CStr("HKLM\Software\McAfee.com\Agent\Apps\MPS"), CStr("State") )
  358.     If 0 = dwState Then
  359.         MPS_IsEnabled = 0
  360.     Else
  361.         MPS_IsEnabled = 1
  362.     End If
  363.  
  364.     g_localObjReg.obfuscate = bOldOfuscate
  365.  
  366. '}
  367. End Function
  368.  
  369.  
  370. ' /////////////////////////////////////////////////////////////////////////////
  371. ' Application interface with dashboard
  372. ' /////////////////////////////////////////////////////////////////////////////
  373.  
  374. Function IsMPSEnabled()
  375. '{
  376.     Dim szErr
  377.     Dim nIsEnabled
  378.  
  379.     IsMPSEnabled = 0
  380.  
  381.     nIsEnabled = MPS_IsEnabled( szErr )
  382.     IsMPSEnabled = nIsEnabled
  383. '}
  384. End Function
  385.  
  386. Function OnEnableMPS()
  387. '{
  388.     Dim szErr
  389.     Dim dwCommandId
  390.     dwCommandId = ID_MSCIF_ENABLE
  391.     call MPS_InvokeCommand( dwCommandId, szErr )
  392.     
  393.     'Now we have a Timer that calls GetNewMPSState every 1500 msec
  394.     'which in turn calls these functions, so we don't need to call it here...
  395.     'SetDocumentTitleString()
  396. '}
  397. End Function
  398.  
  399. Function OnDisableMPS()
  400. '{
  401.     Dim szErr
  402.     Dim dwCommandId
  403.     dwCommandId = ID_MSCIF_DISABLE
  404.     call MPS_InvokeCommand( dwCommandId, szErr )
  405.  
  406.     'Now we have a Timer that calls GetNewMPSState every 1500 msec
  407.     'which in turn calls these functions, so we don't need to call it here...
  408.     'SetDocumentTitleString()
  409. '}
  410. End Function
  411.  
  412. Function OnVerifyMPS()
  413. '{
  414.     Dim szErr
  415.     Dim dwCommandId
  416.     dwCommandId = ID_MSCIF_CHECKEXPIRY
  417.  
  418.     If False = IsObject( g_localObjOS ) Or g_localObjOS is nothing Then
  419.         Exit Function
  420.     End If
  421.  
  422.     If False = IsObject( g_localObjFS ) Or g_localObjFS is nothing Then
  423.         Exit Function
  424.     End If
  425.  
  426.     Call MPSDisp_OnUnload()
  427.  
  428.     Dim eResult 
  429.     Dim szPath
  430.     szPath = GetObjectPath( MPS_CLSID, g_localObjOS, g_localObjFS )
  431.     szPath = CStr(szPath & "\" & MPS_APP_NAME)
  432.     LaunchProgram szPath, MPS_CMDARG_VERIFY_STR, eResult 
  433. '}    
  434.  
  435. End Function
  436.  
  437. Function SignIn()
  438. '{
  439.     Dim szErr
  440.     Dim dwCommandId
  441.     dwCommandId = ID_USER_LOGIN
  442.     call MPS_InvokeCommand( dwCommandId, szErr )
  443.  
  444.     'Now we have a Timer that calls GetNewMPSState every 1500 msec
  445.     'which in turn calls these functions, so we don't need to call it here...
  446.     'Dim userType
  447.     'userType = MPS_GetUserType( szErr )
  448.  
  449.     'SetSignedInState( userType )
  450. '}
  451. End Function
  452.  
  453. Function SignOut()
  454. '{
  455.     Dim szErr
  456.     Dim dwCommandId
  457.     dwCommandId = ID_USER_LOGOUT
  458.     call MPS_InvokeCommand( dwCommandId, szErr )
  459.  
  460.     'Now we have a Timer that calls GetNewMPSState every 1500 msec
  461.     'which in turn calls these functions, so we don't need to call it here...
  462.     'Dim userType
  463.     'userType = MPS_GetUserType( szErr )
  464.  
  465.     'SetSignedInState( userType )
  466.  
  467. '}
  468. End Function
  469.  
  470. Function ViewEventLog()
  471. '{
  472.     Dim szErr
  473.     Dim dwCommandId
  474.     dwCommandId = ID_MSCIF_EVENTLOG
  475.     call MPS_InvokeCommand( dwCommandId, szErr )
  476. '}
  477. End Function
  478.  
  479. Function ConfigureUser()
  480. '{
  481.     Dim szErr
  482.     Dim dwCommandId
  483.     dwCommandId = ID_MSCIF_USERS
  484.     call MPS_InvokeCommand( dwCommandId, szErr )
  485. '}
  486. End Function
  487.  
  488. Function ShowOptions()
  489. '{
  490.     Dim szErr
  491.     Dim dwCommandId
  492.     dwCommandId = ID_USER_CONFIGURATION
  493.     call MPS_InvokeCommand( dwCommandId, szErr )
  494. '}
  495. End Function
  496.  
  497. Function ShowAbout()
  498. '{
  499.     Dim szErr
  500.     Dim dwCommandId
  501.     dwCommandId = ID_MSCIF_ABOUT
  502.     call MPS_InvokeCommand( dwCommandId, szErr )
  503. '}
  504. End Function
  505.  
  506.  
  507. '// 
  508. '// IsMPS4Installed()
  509. '// 
  510. '// Return Values:
  511. '// -2: If VSO is not installed.
  512. '// -1: Error code.
  513. '// 0: If Old VSO (3.X) is installed.
  514. '// 1: If VSO 4 is installed.
  515. Function IsMPS4Installed( objReg, objOS, objFS )
  516. '{
  517.   Dim eResult
  518.  
  519. Const MPS_CLSID                          = "{13DB6EFF-AF1B-483e-8F7B-F1978AD6D4E1}"
  520.  
  521.   IsMPS4Installed = -1
  522.   If False = IsObject( objOS ) Then
  523.     Exit Function
  524.   End If
  525.  
  526.   If objOS is nothing Then
  527.     Exit Function
  528.   End If
  529.  
  530.   IsMPS4Installed = -2
  531.   eResult = objOS.IsObjectInstalled( MPS_CLSID, "4,0,0,0" )
  532.  
  533.   Select Case eResult
  534.   '{
  535.     Case 0 '// MCINST_OS_NO_VERSION_INFO
  536.       Exit Function
  537.     Case 1 '// MCINST_OS_OLDER_VERSION_EXISTS
  538.       IsMPS4Installed = 0
  539.     Case 2 '// MCINST_OS_OBJECT_EXISTS
  540.       IsMPS4Installed = 1
  541.     Case 3 '// MCINST_OS_OBJECT_NOT_FOUND
  542.       IsMPS4Installed = -2
  543.   '}
  544.   End Select
  545. '}
  546. End Function
  547.  
  548.  
  549. '// 
  550. '// IsMPS6Installed()
  551. '// 
  552. '// Return Values:
  553. '// -2: If MPS6 is not installed.
  554. '// -1: Error code.
  555. '// 1: If MPS 6 and above is installed.
  556. Function IsMPS6Installed(objReg, objOS, objFS)
  557. '{
  558.     
  559.     Dim szPath, eResult
  560.     szPath = objReg.RegQueryValue(MPS6_REG_KEY & "\" & MPS6_CLSID, MPS6_REGVAL_INSTALL_LOC)
  561.  
  562.     If ( Len(szPath) > 0) Then
  563.         szPath = CStr(szPath) & MPS6_APPNAME
  564.     Else
  565.         IsMPS6Installed = -2
  566.         Exit Function
  567.     End If
  568.  
  569.     eResult = objOS.CheckVersion(szPath, MPS6_MIN_VER)
  570.  
  571.     ' I am not returning an error code. If 6,0,0,0 and above is not present then MPS is not
  572.     ' installed...
  573.  
  574.     ' MCINST_OS_OBJECT_EXISTS = 2
  575.  
  576.     If (2 = eResult) Then
  577.       IsMPS6Installed = 1
  578.     Else
  579.       IsMPS6Installed = -2
  580.     End If
  581.  
  582. '}
  583. End Function
  584.  
  585. '// 
  586. '// IsMPSInstalled()
  587. '// 
  588. '// Return Values:
  589. '// -2: If MPS is not installed.
  590. '// -1: Error code.
  591. '// 0: If Old MPS (3.X or MPS 4.x) is installed.
  592. '// 1: If MPS 6 and above is installed.
  593. Function IsMPSInstalled(objReg, objOS, objFS)
  594. '{
  595.  
  596.     Dim nResult
  597.     nResult = IsMPS6Installed(objReg, objOS, objFS)
  598.  
  599.     If -2 = nResult Then
  600.     '{
  601.         nResult = IsMPS4Installed(objReg, objOS, objFS)
  602.     '}
  603.     End If 
  604.    
  605.    IsMPSInstalled = nResult
  606.  
  607. '}
  608. End Function
  609.  
  610.  
  611. '1 = Expired, 0 = Not Expired
  612. Function IsMPSExpired()
  613. '{
  614.     Dim    szExpDate
  615.  
  616.     If g_localObjInstaller is nothing Or Not IsObject( g_localObjInstaller ) Then
  617.         IsMPSExpired = 1
  618.         Exit Function
  619.     End If
  620.  
  621.     If False = WillMPSProductExpire() Then
  622.         IsMPSExpired = 0
  623.         Exit Function
  624.     End If
  625.  
  626.     szExpDate = ""
  627.     g_localObjInstaller.GetExpiryDate "HKLM\Software\McAfee.com\Privacy Service", "Settings", szExpDate 
  628.  
  629.     If Len(szExpDate) <> 8 Then
  630.         IsMPSExpired = 1
  631.         Exit Function
  632.     End If
  633.  
  634.     Dim szExpYear, szExpMonth, szExpDay
  635.     szExpYear = Left( szExpDate, 4 )
  636.     szExpMonth = Mid( szExpDate, 5, 2 )
  637.     szExpDay = Mid( szExpDate, 7, 2)
  638.  
  639.     Dim glExpYear, glExpMonth, glExpDay
  640.  
  641.     glExpYear  = CStr( szExpYear )
  642.     glExpMonth = CStr( szExpMonth )
  643.     glExpDay   = CStr( szExpDay )
  644.  
  645.     Dim actualExpiryDate
  646.     actualExpiryDate = DateSerial( glExpYear, glExpMonth, glExpDay )
  647.  
  648.     If False = IsDate( actualExpiryDate ) Then
  649.     '{
  650.         'Tampered Expiry setting
  651.         IsMPSExpired = 1
  652.         Exit Function
  653.     '}
  654.     End If
  655.  
  656.     If DateDiff( "d", Date, actualExpiryDate ) >= 0 Then
  657.         IsMPSExpired = 0
  658.     Else
  659.         IsMPSExpired = 1
  660.     End If
  661.         
  662. '}
  663. End Function
  664.  
  665. Function WillMPSProductExpire()
  666. '{
  667.   Dim sTemp
  668.  
  669.   WillMPSProductExpire = True
  670.  
  671.   If IsObject(gobjReg) Then
  672.   '{
  673.     If not gobjReg is nothing Then
  674.     '{
  675.       gobjReg.Obfuscate = True
  676.       
  677.         sTemp = Trim(gobjReg.RegQueryValue(REG_MPS_KEY, REG_MPS_PRODUCTTYPE_NAME))
  678.         If IsNumeric(sTemp) And Len(sTemp) > 0 Then
  679.           If (CLng(sTemp) And MPS_PRODUCT_INSTALL_TYPE_NODIE_NOUPDATES) <> 0 Then
  680.             WillMPSProductExpire = False
  681.           End If
  682.         End If
  683.  
  684.       gobjReg.Obfuscate = False
  685.     '}
  686.     End If
  687.   '}
  688.   End If
  689. '}
  690. End Function
  691.  
  692. '--------------------------------------------------------------------------------
  693. ' To Support Retail products in Dashboard, we need to have a set of function
  694. ' that check for Retail product state (Expired/Enabled/Disabled) etc
  695.  
  696. '1 = Installed, 0 = Not Installed, -1 = Error
  697. Function IsRetailMPSInstalled()
  698. '{
  699.     Dim bOldOfuscate, bRetail
  700.     If g_localObjReg Is Nothing Then
  701.         IsRetailMPSInstalled = -1
  702.         Exit Function
  703.     End If
  704.  
  705.     bRetail = 0
  706.     bOldOfuscate = g_localObjReg.obfuscate
  707.     g_localObjReg.obfuscate = True
  708.     bRetail = g_localObjReg.RegQueryValue( CStr("HKLM\Software\McAfee.com\Agent\Apps\MPS"), CStr("Retail") )
  709.     If 1 = bRetail Then
  710.         IsRetailMPSInstalled = 1
  711.     Else
  712.         IsRetailMPSInstalled = 0
  713.     End If
  714.     g_localObjReg.obfuscate = bOldOfuscate
  715. '}
  716. End Function
  717.  
  718. '1 = Expired, 0 = Not Expired
  719. Function IsRetailMPSExpired()
  720. '{
  721.     Dim    szExpDate
  722.  
  723.     If g_localObjInstaller is nothing Or Not IsObject( g_localObjInstaller ) Then
  724.         IsRetailMPSExpired = 1
  725.         Exit Function
  726.     End If
  727.  
  728.     ' If Product type says its perpetual product return not expired...        
  729.     If False = WillMPSProductExpire() Then
  730.         IsRetailMPSExpired = 0
  731.         Exit Function
  732.     End If
  733.  
  734.     szExpDate = ""
  735.     g_localObjInstaller.GetExpiryDate "HKLM\Software\McAfee.com\Privacy Service", "Settings", szExpDate 
  736.  
  737.     If Len(szExpDate) <> 8 Then
  738.         IsRetailMPSExpired = 1
  739.         Exit Function
  740.     End If
  741.  
  742.     Dim szExpYear, szExpMonth, szExpDay
  743.     szExpYear = Left( szExpDate, 4 )
  744.     szExpMonth = Mid( szExpDate, 5, 2 )
  745.     szExpDay = Mid( szExpDate, 7, 2)
  746.  
  747.     Dim glExpYear, glExpMonth, glExpDay
  748.  
  749.     glExpYear  = CStr( szExpYear )
  750.     glExpMonth = CStr( szExpMonth )
  751.     glExpDay   = CStr( szExpDay )
  752.  
  753.     Dim actualExpiryDate
  754.     actualExpiryDate = DateSerial( glExpYear, glExpMonth, glExpDay )
  755.  
  756.     If False = IsDate( actualExpiryDate ) Then
  757.     '{
  758.         'Tampered Expiry setting
  759.         IsRetailMPSExpired = 1
  760.         Exit Function
  761.     '}
  762.     End If
  763.  
  764.     If DateDiff( "d", Date, actualExpiryDate ) >= 0 Then
  765.         IsRetailMPSExpired = 0
  766.     Else
  767.         IsRetailMPSExpired = 1
  768.     End If
  769.         
  770. '}
  771. End Function
  772.  
  773. '// 
  774. '// IsRetailMPSEnabled(): Return Values.
  775. '//
  776. '// -1: Error Code
  777. '// 0: Application is not running
  778. '// 1: Application is running.
  779. Function IsRetailMPSEnabled()
  780. '{
  781.     Dim bOldOfuscate, dwState
  782.     If g_localObjReg Is Nothing Then
  783.         IsRetailMPSEnabled = -1
  784.         Exit Function
  785.     End If
  786.  
  787.     dwState = 0
  788.     bOldOfuscate = g_localObjReg.obfuscate
  789.     g_localObjReg.obfuscate = True
  790.     dwState = g_localObjReg.RegQueryValue( CStr("HKLM\Software\McAfee.com\Agent\Apps\MPS"), CStr("State") )
  791.     If 1 = dwState Then
  792.         IsRetailMPSEnabled = 1
  793.     Else
  794.         IsRetailMPSEnabled = 0
  795.     End If
  796.     g_localObjReg.obfuscate = bOldOfuscate
  797. '}
  798. End Function
  799.  
  800. '--------------------------------------------------------------------------------